#ifndef WIZ_H
#define WIZ_H

#include <M_Code_plugin.h>
#include <M_Code_exception.h>
#include <wx/bitmap.h>

class wxWizard;
class wxWizardPageSimple;
class WizProjectPathPanel;
class WizFilePathPanel;
class WizCompilerPanel;
class WizBuildTargetPanel;
class WizGenericSingleChoiceList;
class WizGenericSelectPathPanel;

struct WizardInfo {
  TemplateOutputType output_type;
  wxString title;
  wxString cat;
  wxString script;
  wxBitmap templatePNG;
  wxBitmap wizardPNG;
  wxString xrc;
};

WX_DECLARE_OBJARRAY( WizardInfo, Wizards );

WX_DEFINE_ARRAY( wxWizardPageSimple*, WizPages );

class Wiz : public cbWizardPlugin {
  public:
    Wiz();
    ~Wiz();
    Wiz& operator=( M_Code_unused const Wiz& rhs ) {
      m_Throw( _T( "Can't assign an Wiz* !!!" ) );
      return *this;
    }
    int GetCount() const;
    TemplateOutputType GetOutputType( int index ) const;
    wxString GetTitle( int index ) const;
    wxString GetDescription( int index ) const;
    wxString GetCategory( int index ) const;
    const wxBitmap& GetBitmap( int index ) const;
    wxString GetScriptFilename( int index ) const;
    CompileTargetBase* Launch( int index, wxString* pFilename = 0 );
    CompileTargetBase* RunProjectWizard( wxString* pFilename );
    CompileTargetBase* RunTargetWizard( wxString* pFilename );
    CompileTargetBase* RunFilesWizard( wxString* pFilename );
    CompileTargetBase* RunCustomWizard( wxString* pFilename );
    void AddWizard( TemplateOutputType otype, const wxString& title, const wxString& cat, const wxString& script,
                    const wxString& templatePNG, const wxString& wizardPNG,  const wxString& xrc );
    TemplateOutputType GetWizardType();
    void EnableWindow( const wxString& name, bool enable );
    void CheckCheckbox( const wxString& name, bool check );
    bool IsCheckboxChecked( const wxString& name );
    void FillComboboxWithCompilers( const wxString& name );
    void FillContainerWithSelectCompilers( const wxString& name, const wxString& validCompilerIDs );
    void AppendContainerWithSelectCompilers( const wxString& name, const wxString& validCompilerIDs );
    wxString GetCompilerFromCombobox( const wxString& name );
    void FillContainerWithCompilers( const wxString& name, const wxString& compilerID, const wxString& validCompilerIDs );
    wxString GetComboboxStringSelection( const wxString& name );
    int GetComboboxSelection( const wxString& name );
    void SetComboboxSelection( const wxString& name, int sel );
    void SetComboboxValue( const wxString& name, const wxString& value );
    wxString GetComboboxValue( const wxString& name );
    int GetRadioboxSelection( const wxString& name );
    void SetRadioboxSelection( const wxString& name, int sel );
    int GetListboxSelection( const wxString& name );
    wxString GetListboxSelections( const wxString& name );
    wxString GetListboxStringSelections( const wxString& name );
    void SetListboxSelection( const wxString& name, int sel );
    wxString GetCheckListboxChecked( const wxString& name );
    wxString GetCheckListboxStringChecked( const wxString& name );
    bool IsCheckListboxItemChecked( const wxString& name, unsigned int item );
    void CheckCheckListboxItem( const wxString& name, unsigned int item, bool check );
    void SetTextControlValue( const wxString& name, const wxString& value );
    wxString GetTextControlValue( const wxString& name );
    void SetSpinControlValue( const wxString& name, int value );
    int GetSpinControlValue( const wxString& name );
    wxString GetProjectPath();
    wxString GetProjectName();
    wxString GetProjectFullFilename();
    wxString GetProjectTitle();
    wxString GetCompilerID();
    bool GetWantDebug();
    wxString GetDebugName();
    wxString GetDebugOutputDir();
    wxString GetDebugObjectOutputDir();
    bool GetWantRelease();
    wxString GetReleaseName();
    wxString GetReleaseOutputDir();
    wxString GetReleaseObjectOutputDir();
    wxString GetTargetCompilerID();
    bool GetTargetEnableDebug();
    wxString GetTargetName();
    wxString GetTargetOutputDir();
    wxString GetTargetObjectOutputDir();
    wxString GetFileName();
    wxString GetFileHeaderGuard();
    bool GetFileAddToProject();
    int GetFileTargetIndex();
    void SetFilePathSelectionFilter( const wxString& filter );
    void SetCompilerDefault( const wxString& defCompilerID );
    void SetDebugTargetDefaults( bool wantDebug, const wxString& debugName, const wxString& debugOut, const wxString& debugObjOut );
    void SetReleaseTargetDefaults( bool wantRelease, const wxString& releaseName, const wxString& releaseOut, const wxString& releaseObjOut );
    int FillContainerWithChoices( const wxString& name, const wxString& choices );
    int AppendContainerWithChoices( const wxString& name, const wxString& choices );
    wxString  GetWizardScriptFolder( void );
    void AddInfoPage( const wxString& pageId, const wxString& intro_msg );
    void AddFilePathPage( bool showHeaderGuard );
    void AddProjectPathPage();
    void AddCompilerPage( const wxString& compilerID, const wxString& validCompilerIDs, bool allowCompilerChange = true, bool allowConfigChange = true );
    void AddBuildTargetPage( const wxString& targetName, bool isDebug, bool showCompiler = false, const wxString& compilerID = wxEmptyString, const wxString& validCompilerIDs = _T( "*" ), bool allowCompilerChange = true );
    void AddGenericSingleChoiceListPage( const wxString& pageName, const wxString& descr, const wxString& choices, int defChoice );
    void AddGenericSelectPathPage( const wxString& pageId, const wxString& descr, const wxString& label, const wxString& defValue );
    void AddPage( const wxString& panelName );
    void Finalize();
    void RegisterWizard();
    wxString FindTemplateFile( const wxString& filename );
  protected:
    void OnAttach();
    void Clear();
    void CopyFiles( M_Code_Project* theproject, const wxString&  prjdir, const wxString& srcdir );
    wxString GenerateFile( const wxString& basePath, const wxString& filename, const wxString& contents );
    Wizards m_Wizards;
    wxWizard* m_pWizard;
    WizPages m_Pages;
    WizProjectPathPanel* m_pWizProjectPathPanel;
    WizFilePathPanel* m_pWizFilePathPanel;
    WizCompilerPanel* m_pWizCompilerPanel;
    WizBuildTargetPanel* m_pWizBuildTargetPanel;
    int m_LaunchIndex;
    wxString m_LastXRC;
    wxString m_DefCompilerID;
    bool m_WantDebug;
    wxString m_DebugName;
    wxString m_DebugOutputDir;
    wxString m_DebugObjOutputDir;
    bool m_WantRelease;
    wxString m_ReleaseName;
    wxString m_ReleaseOutputDir;
    wxString m_ReleaseObjOutputDir;
    wxString m_WizardScriptFolder;
  private:
    Wiz( M_Code_unused const Wiz& rhs );
};

#endif
